//
//  HTWishCell.m
//  HeartTravel
//
//  Created by lanou on 15/10/26.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "HTWishCell.h"
#import "UIImageView+WebCache.h"
@interface HTWishCell ()

@property (nonatomic, strong) UIView *line1;
@property (nonatomic, strong) UIView *line2;

@end

@implementation HTWishCell
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat width = frame.size.width;
        CGFloat height = frame.size.height;
        _labelBGView = [[UIView alloc] initWithFrame:CGRectMake(5, 0, width-10, height - 40)];
        _labelBGView.layer.cornerRadius = 15;
        _labelBGView.layer.masksToBounds = YES;
        _labelBGView.backgroundColor = [UIColor colorWithRed:arc4random()%256 / 255.0 green:arc4random()%256 / 255.0 blue:arc4random()%256 / 255.0 alpha:1.0];
        _label = [[UILabel  alloc] initWithFrame:CGRectMake(10, 10, width - 20,height - 60)];
        _label.numberOfLines = 0;
        _label.font = [UIFont systemFontOfSize:15];
        _label.textColor = [UIColor whiteColor];
        
        
        _userILView = [[HTILView alloc] initWithFrame:CGRectMake(0, height - 40, width, 40)];
        _userILView.imageView.frame = CGRectMake(10, 5, 30, 30);
        _userILView.label.frame = CGRectMake(50, 10, width - 50, 20);
        _userILView.imageView.layer.cornerRadius = 15;
        _userILView.imageView.layer.masksToBounds = YES;
        
        _line1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, height-40)];
        _line1.backgroundColor = [UIColor whiteColor];
        
        _line2 = [[UIView alloc] initWithFrame:CGRectMake(width-5, 0, 5, height - 40)];
        _line2.backgroundColor = [UIColor whiteColor];
        
        
        [self.contentView addSubview:_labelBGView];
        [self.contentView addSubview:_line1];
        [self.contentView addSubview:_line2];
        [self.contentView addSubview:_label];
        [self.contentView addSubview:_userILView];
    }
    return self;
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    _labelBGView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height - 40)];
    _label = [[UILabel  alloc] initWithFrame:CGRectMake(10, 10, width - 20,height - 60)];
    _userILView = [[HTILView alloc] initWithFrame:CGRectMake(0, height - 40, width, 40)];
    _line1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, height-40)];
    _line2 = [[UIView alloc] initWithFrame:CGRectMake(0, width-5, 5, height - 40)];
}

- (void)setConfigureModel:(HTWishModel *)configureModel {
    
    _configureModel = configureModel;
    _label.text = configureModel.content;
    [_userILView.imageView sd_setImageWithURL:[NSURL URLWithString:configureModel.avatar]];
    _userILView.label.text = configureModel.user_name;
}


@end
